// pages/personal/sale/tx-detail.js

const app = getApp()
const pool = new Map()
Page({

    /**
     * 页面的初始数据
     */
    data: {
        type: 5,
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {
        this.loadData()
    },

    loadData() {
        let tab = pool.get(this.data.type)
        if (!tab) {
            pool.set(this.data.type, tab)
        }

        wx.showLoading({
            title: '加载中...',
        })
        this.setData({
            loading: true
        })
        app.http.get("city/tiny-station/get-cash-detail", {
            data: {
                id: this.data.type,
            }
        }).then(res => {
            this.setData({
                list: res.data
            })
            wx.hideLoading()
            wx.stopPullDownRefresh()
            this.setData({
                loading: false
            })
        }).catch(err => {
            app.wxToast.error(err.message)
            this.setData({
                loading: false
            })
        })
    },

    typeClick(evt) {
        const type = evt.currentTarget.dataset.type
        if (this.data.type != type) {
            this.setData({
                type
            })
            this.loadData()
        }
    },
    onReachBottom() {
        this.loadData()
    },
    onPullDownRefresh() {
        pool.set(this.data.type, null)
        this.loadData()
    }
})